package com.damon.controller;

import java.util.UUID;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/wcs")
public class WcsTestController {
	@RequestMapping(value = "/test1",method = RequestMethod.POST,produces="application/json;charset=UTF-8")
	public String wcsPost(HttpServletRequest request,HttpServletResponse response,@RequestBody(required=false) String json) {
		System.out.println(json);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("code", "1");
		jsonObject.put("content", "");
		jsonObject.put("message", "");
		return jsonObject.toString();
	}
	@RequestMapping(value = "/test2",method = RequestMethod.POST,produces="application/json;charset=UTF-8")
	public String wcsPost2(HttpServletRequest request,HttpServletResponse response,@RequestBody(required=false) String json) {
		System.out.println(json);
		
		//json构造
		JSONObject parentJson = new JSONObject();
		parentJson.put("code", "1");
		parentJson.put("message", "");
		
		JSONObject sonJson = new JSONObject();
		sonJson.put("tenantId", "tenantId");
		sonJson.put("warehouseNo", "warehouseNo");
		sonJson.put("orderNo", "orderNo");
		JSONArray list = new JSONArray();
		JSONObject listOne = new JSONObject();
		listOne.put("packageNo", "packageNo"+UUID.randomUUID());
		listOne.put("waybillNo", "waybillNo");
		listOne.put("carrierNo", "carrierNo");
		listOne.put("province", "province");
		listOne.put("city", "city");
		listOne.put("county", "county");
		listOne.put("distributionRoadCode", "distributionRoadCode");
		listOne.put("distributionRoadName", "distributionRoadName");
		listOne.put("printSiteName", "printSiteName");
		listOne.put("customerId", "customerId");
		listOne.put("checkWeight", 1);
		listOne.put("estimatedWeight", 2);
		listOne.put("weightError", 3);
		list.put(listOne);
		list.put(listOne);
		sonJson.put("packageList", list);
		parentJson.put("content", sonJson.toString());
		
		return parentJson.toString();
	}
}
